﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;


namespace Fusion
{

    public class Cursor
    {
        #region Attributes

        public Vector2 pointer; // current position of the mouse
        public Vector2 pointerMovement; // cursor movement

        public int[] buttons = new int[5];
        public Vector2[] pins = new Vector2[5]; // selection pin
        public bool[] pinned = new bool[5];

        public int wheel; // wheel state
        public int wheelMove; // wheel movement
                
        
        #endregion

        #region Methods

        public virtual void Update()
        {
            // Mouse cursor
            pointerMovement = Input.MousePixel - pointer;
            pointer = Input.MousePixel;

            // Wheel
            if( wheel != Input.MouseWheel )
            {
                wheelMove = Input.MouseWheel - wheel;
                wheel = Input.MouseWheel;
            }
            else
                wheelMove = 0;

            // Button State
            buttons[0] = Input.MouseLeft;
            buttons[1] = Input.MouseRight;
            buttons[2] = Input.MouseMiddle;
            buttons[3] = Input.Mouse4;
            buttons[4] = Input.Mouse5;

            // Pins
            for( int i=0; i<5; i++ )
            {

                if( buttons[i] > 0 )
                    pinned[i] = true;
                else
                {
                    pinned[i] = false;
                    pins[i] = pointer;
                }
            }
        }

        #endregion
    }
}
